import router from "./index";
import store from "../store";
import { ElMessage as Message } from 'element-plus'

const whiteList = ['/login']
router.beforeEach(async (to, from, next) => {
    console.log('test',store.state.user)
    if(store.state.user.userName && to.path !== '/login'){
        Message.error('请重新登录！');
        return {path:'/login'}
    }
    if(to.meta.userType && to.meta.userType > store.state.user.userType){
        Message.error('权限不足')
        return {
            path: from.path
        }
    }
})